//
//  WLBaseVController.m
//  WanLian
//
//  Created by muzhuang on 2018/8/30.
//  Copyright © 2018年 wanlian. All rights reserved.
//

#import "WLBaseVController.h"

@interface WLBaseVController ()

@end

@implementation WLBaseVController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = YES;
    if (@available(iOS 11.0, *)) {
        [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        // 这部分使用到的过期api
        self.automaticallyAdjustsScrollViewInsets = NO;
#pragma clang diagnostic pop
    }
    
    self.view.backgroundColor = wlUIColorRGB(0xFAFAFA);
    
    if (self.navigationItem.leftBarButtonItem == nil && self.navigationController.viewControllers.count >1)
    {
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
        backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        backButton.frame = CGRectMake(0, 0, 50, 44);
        [backButton setImage:[UIImage imageNamed:@"arrow_back"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(popBackButtonAction) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *leftBar = [[UIBarButtonItem alloc]initWithCustomView:backButton];
        self.navigationItem.leftBarButtonItem = leftBar;
    }
}

- (void)popBackButtonAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
